import { isEmpty } from 'lodash';
import { request } from '@/sheep/request';

const route = {
  path: 'config',
  name: 'shop.admin.config',
  component: () => import('@/app/shop/admin/config/index.vue'),
  meta: {
    title: '配置',
  },
};

const api = {
  basic: (data) =>
    request({
      url: 'shop/admin/config/basic',
      method: isEmpty(data) ? 'GET' : 'PUT',
      data,
      options: {
        showSuccessMessage: !isEmpty(data),
      },
    }),
  order: (data) =>
    request({
      url: 'shop/admin/config/order',
      method: isEmpty(data) ? 'GET' : 'PUT',
      data,
      options: {
        showSuccessMessage: !isEmpty(data),
      },
    }),
  recharge: (data) =>
    request({
      url: 'shop/admin/config/rechargeWithdraw',
      method: isEmpty(data) ? 'GET' : 'PUT',
      data,
      options: {
        showSuccessMessage: !isEmpty(data),
      },
    }),
  platformStatus: () =>
    request({
      url: 'shop/admin/config/platformStatus',
      method: 'GET',
    }),
  platform: (platform, data) =>
    request({
      url: 'shop/admin/config/platform/' + platform,
      method: isEmpty(data) ? 'GET' : 'PUT',
      data,
      options: {
        showSuccessMessage: !isEmpty(data),
      },
    }),
  commission: (data) =>
    request({
      url: 'shop/admin/config/commission',
      method: isEmpty(data) ? 'GET' : 'PUT',
      data,
      options: {
        showSuccessMessage: !isEmpty(data),
      },
    }),
  dispatch: (data) =>
    request({
      url: 'shop/admin/config/dispatch',
      method: isEmpty(data) ? 'GET' : 'PUT',
      data,
      options: {
        showSuccessMessage: !isEmpty(data),
      },
    }),
  goods: (data) =>
    request({
      url: 'shop/admin/config/goods',
      method: isEmpty(data) ? 'GET' : 'PUT',
      data,
      options: {
        showSuccessMessage: !isEmpty(data),
      },
    }),
  getPlatformUrl: () =>
    request({
      url: 'shop/admin/config/getPlatformUrl',
      method: 'GET',
    }),
};

export { route, api };
